package com.example.prom.utils;

import com.google.common.util.concurrent.ThreadFactoryBuilder;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * Description
 *
 * @author DangWen
 */
public class ThreadPoolUtil {

    /**
     * 静态线程池，用于解决非注入场景的多线程问题
     */
    private static final ThreadFactory namedThreadFactory = new ThreadFactoryBuilder().setNameFormat("dw-thread-call-runner-%d").build();
    public static final ThreadPoolExecutor threadPoolExecutor =  new ThreadPoolExecutor(10, 10, 3000L,
            TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(1000),
            namedThreadFactory, new ThreadPoolExecutor.AbortPolicy());
}
